/* 
 * Copyright (C), 2016-2020, 厦门盈欣宝金融信息服务有限公司
 * Project Name :bootmybatis
 * File Name: com.example.bootmybatis.controller
 * Encoding UTF-8 
 * Version: 1.0 
 * Date: 2018-06-07 16:33
 * History:  
 * 1. Date: 2018-06-07
 *    Author: guojm 
 *    Modification: 新建
 * 2. ...
 */
package org.easytouseit.mybatis.controller;


import org.easytouseit.mybatis.model.UserDomain;
import org.easytouseit.mybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author guojm
 * @version V1.0
 * @date 2018-06-07
 */
@Controller
@RequestMapping(value = "/user")
public class UserController {

    @Autowired
    private UserService userService;

    @ResponseBody
    @PostMapping("/add")
    public UserDomain addUser(UserDomain user){
        userService.addUser(user);
        return user;
    }

    @ResponseBody
    @GetMapping("/all")
    public Object findAllUser(
            @RequestParam(name = "pageNum", required = false, defaultValue = "1")
                    int pageNum,
            @RequestParam(name = "pageSize", required = false, defaultValue = "10")
                    int pageSize){
        return userService.findAllUser(pageNum,pageSize);
    }
}
